{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "9055b504",
   "metadata": {},
   "source": [
    "**2022/9/5 礼仪的week03**"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c5f9dca6",
   "metadata": {},
   "source": [
    "# 本周学习目标"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6ad6ff92",
   "metadata": {},
   "source": [
    "> 1.模块\n",
    ">\n",
    "> 2.变量\n",
    ">\n",
    "> 3.循环遍历"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1e4457b6",
   "metadata": {},
   "source": [
    "# 1.模块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "050b5c65",
   "metadata": {},
   "source": [
    "## (一)模块 [标准库](https://docs.python.org/3/library/index.html)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cb927a63",
   "metadata": {},
   "source": [
    "> Python创始人团队为后面使用这门编程语言的人们提供的解决**日常生活可能使用到的功能，而制作的可以方便使用的模块**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "9dcaa8eb",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c07fe594",
   "metadata": {},
   "source": [
    "* 纪元(1970.1.1)\n",
    "* 时间戳 (有必要了解) bug可以通过时间戳的时间找到当时那刻出问题的时间并由此找到问题出处\n",
    "\n",
    "time.time()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "0de9520d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1664000450.2118104"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 纪元(1970.1.1\n",
    "time.time()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "0a87577d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=9, tm_mday=24, tm_hour=14, tm_min=9, tm_sec=51, tm_wday=5, tm_yday=267, tm_isdst=0)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "741cf62e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=9, tm_mday=24, tm_hour=6, tm_min=10, tm_sec=3, tm_wday=5, tm_yday=267, tm_isdst=0)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.gmtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "26cc3c8b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Sat Sep 24 14:10:16 2022'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.asctime(time.localtime())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dd5a760e",
   "metadata": {},
   "source": [
    "## (二)模块 - 开源模块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4e7ddec3",
   "metadata": {},
   "source": [
    "> 1.因为代码开源\n",
    ">\n",
    "> 2.集合全领域（全人类）的需求\n",
    ">\n",
    ">3.按照**国标开放的模块库**"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e589648e",
   "metadata": {},
   "source": [
    "> [资源地址](https://pypi.org/)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "803a2418",
   "metadata": {},
   "source": [
    "## (三)模块 - 自定义模块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "02d70952",
   "metadata": {},
   "source": [
    "> 1.不愿意开源的有一定知识产权的（开放API租用形式）\n",
    ">\n",
    "> 2.自己用，写的不好，开源要丢人"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3d38aa54",
   "metadata": {},
   "source": [
    "# 2.变量"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3821e22d",
   "metadata": {},
   "source": [
    ">> **1.变量声明（命名）规则**\n",
    ">\n",
    "> 1.变量名只能是*字母、数字或下划线*的任意组合\n",
    ">\n",
    "> 2.变量名的第一个字符不能是*数字*  ps:013zeyan = 013(不可）  zeyan013 = 013(可)\n",
    ">\n",
    ">3.以下关键词不能声明为变量名\n",
    "['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda','not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield'] 在jupyter环境中显示绿色的不能命名"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bf1894cf",
   "metadata": {},
   "source": [
    "* 有空间要有名字，也要有东西！\n",
    "\n",
    "  赋值+命名"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "02d180e3",
   "metadata": {},
   "outputs": [],
   "source": [
    "网三_01= \"zhengliyi\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "2023b10f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'zhengliyi'"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_01"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "eabbae3a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2110120088 2110120088\n"
     ]
    }
   ],
   "source": [
    "# 案例（关于变量）\n",
    "网一_01_ID = \"2110120088\"\n",
    "\n",
    "网一_02_ID = 网一_01_ID\n",
    "\n",
    "print(网一_01_ID,网一_02_ID)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "0c6ddce3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "郑礼仪 郑礼仪2号\n",
      "郑礼仪2号 郑礼仪2号\n"
     ]
    }
   ],
   "source": [
    "# 案例\n",
    "网三_01= \"郑礼仪\"\n",
    "网三_02= \"郑礼仪2号\"\n",
    "print(网三_01,网三_02)\n",
    "网三_01= \"郑礼仪2号\"\n",
    "print(网三_01,网三_02)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9d4b620d",
   "metadata": {},
   "source": [
    "**上面的例子就证明了，python是，一门翻译的语言——边输入边翻译** \n",
    "\n",
    "**变量的值是可以发生改变的，取决于最后一次赋值操作**"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "499697af",
   "metadata": {},
   "source": [
    "* xiaoyuke  2个案例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "669503d9",
   "metadata": {},
   "outputs": [],
   "source": [
    "x = 113"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "5146f947",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "113\n"
     ]
    }
   ],
   "source": [
    "print(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2c780536",
   "metadata": {},
   "source": [
    "**(一)不同变量的值可以进行传递**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "17bfa940",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n"
     ]
    }
   ],
   "source": [
    "x = 3\n",
    "y = 5\n",
    "y = x\n",
    "print(y)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4f7a59bf",
   "metadata": {},
   "source": [
    "最后被赋值为x的值"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "40c5265b",
   "metadata": {},
   "source": [
    "**（二）调换二个变量的值**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "6cfefa67",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5 3\n"
     ]
    }
   ],
   "source": [
    "x = 3\n",
    "y = 5\n",
    "z = x\n",
    "x = y \n",
    "y = z\n",
    "print(x,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "7ec3f168",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5 3\n"
     ]
    }
   ],
   "source": [
    "x = 3\n",
    "y = 5 \n",
    "x,y = y,x \n",
    "print(x,y)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4719480f",
   "metadata": {},
   "source": [
    "# 课后作业"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d961d1a0",
   "metadata": {},
   "source": [
    "* 1.课本P4 项目练习（写一遍且运行成功）\n",
    "* 2.思考if 是什么？\n",
    "* 3.思考form是什么？"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
